import { createRouter, createWebHashHistory } from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
import routes from "./routes";
// console.log("🚀 ~ routes:", routes);

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  if (!NProgress.isStarted()) {
    NProgress.start();
  }
  next();
});
router.afterEach((to, from, next) => {
  NProgress.done();
});

//全局进度条的配置
NProgress.configure({
  easing: "ease", // 动画方式
  speed: 700, // 递增进度条的速度
  showSpinner: true, // 是否显示加载ico
  trickleSpeed: 400, // 自动递增间隔
  minimum: 0.3, // 更改启动时使用的最小百分比
  parent: "body", //指定进度条的父容器
});

export default router;
